<!--#include file="functions.asp" -->
<%
'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTTEST2", "MP2", "MP2"
dim sql

  dim InvRegNo  
  'sql = "SELECT RLVOPREFIX, RLVONUM FROM EXJRNLPREF"
  'set RS=cn.execute(sql)
  'InvRegNo = rs("RLVOPREFIX") & String(4-Len(CStr(rs("RLVONUM"))),"0") & CStr(rs("RLVONUM")) 
  'set RS=nothing
  'sql = "UPDATE EXJRNLPREF SET RLVONUM=RLVONUM+1"
  'cn.execute(sql)
  sql = "SELECT REGPREFIX, REGNUM FROM EXJRNLPREF"
  set RS=cn.execute(sql)
  InvRegNo = rs("REGPREFIX") & String(4-Len(CStr(rs("REGNUM"))),"0") & CStr(rs("REGNUM")) 
  set RS=nothing
  sql = "UPDATE EXJRNLPREF SET REGNUM=REGNUM+1"
  cn.execute(sql)
  
  sql = "UPDATE EXILVOHEADER SET "
  sql = sql & "INVNUM='" & request("reqInvoiceNo") & "',"
  sql = sql & "REGNUM='" & InvRegNo & "',"
  sql = sql & "STATUS='INVOICED',"
  sql = sql & "INVDATE='" & request("ReceivedDate") & "',"
  sql = sql & "COMMENTS='" & dblq(request("Notes")) & "',"
  sql = sql & "INVRECBY='" & request("reqReceivedBy") & "',"
  'sql = sql & "DEPARTMENT='" & request("Dept") & "',"
  sql = sql & "COMPCODE='" & request("CompCode") & "',"
  if (request("cbVAT") = "Y") then
  sql = sql & "VATPAIDTOVENDOR='Y',"
  else
  sql = sql & "VATPAIDTOVENDOR='N',"
  end if
  sql = sql & "WHTNAME='" & request("WHTName") & "',"
  sql = sql & "WHTRATE=" & request("WHTRate") & ","
  sql = sql & "VATRATE=" & request("VATRate") & ","
  sql = sql & "WHTAMOUNT=" & request("WHTAmt")  
  sql = sql & " WHERE LVONUM ='" & request("seqnum2")  &"'"

  cn.execute(sql)
  
 'insert history
  sql = "INSERT INTO EXIHISTLVO (SEQNUM, TRANSTYPE,LOCATION,DEPARTMENT,DATE,UPDATEUSER,UPDATESTAMP)"
  sql = sql & " VALUES ("
  sql = sql & request("seqnum3") & ",'"
  sql = sql & "IRC','"
  sql = sql & request("reqReceivedBy") & "','"
  sql = sql & "FINANCE','"
  sql = sql & request("ReceivedDate") & "','"
  sql = sql & usrName & "',"
  sql = sql & "GETDATE() )"
  
  cn.execute(sql)
dim tmpNum
tmpNum = request("seqnum2")
response.redirect "Inv_Print_LVO.asp?seqnum=" & tmpNum

%>
